#include "gsmfr_interface.h"
#include <string.h>
#include "gsm.h"

void WebRtcGSMFR_Version( char *versionStr, short len )
{
	strncpy(versionStr, "1.0.0\n", len);
}

int16_t WebRtcGSMFR_CreateEnc( GSMFR_encinst_t** inst )
{
	*inst=(GSMFR_encinst_t*)gsm_create();

	if(*inst!=NULL)
		return 0;

	return -1;
}

int16_t WebRtcGSMFR_CreateDec( GSMFR_decinst_t** inst )
{
	* inst=(GSMFR_decinst_t*)gsm_create();

	if(*inst!=NULL)
		return 0;

	return -1;
}

int16_t WebRtcGSMFR_FreeEnc( GSMFR_encinst_t* inst )
{
	gsm_destroy((gsm)inst);
	return 0;
}

int16_t WebRtcGSMFR_FreeDec( GSMFR_decinst_t* inst )
{
	gsm_destroy((gsm)inst);
	return 0;
}

int16_t WebRtcGSMFR_Encode( GSMFR_encinst_t* encInst, int16_t* input, int16_t len, int16_t* output )
{
	gsm_encode((gsm)encInst,(gsm_signal*)input,(gsm_byte*)output);
	return 33;

}

int16_t WebRtcGSMFR_EncoderInit( GSMFR_encinst_t* encInst, int16_t mode )
{
	return 0;
}

int16_t WebRtcGSMFR_Decode(GSMFR_decinst_t *GSMdec_inst, const int16_t *encoded, int16_t len, int16_t *decoded, int16_t *speechType)
{
   gsm_decode((gsm)GSMdec_inst,(gsm_byte*)encoded,(gsm_signal*)decoded);
   *speechType = 0;
   return 160;
}

int16_t WebRtcGSMFR_DecodeBwe( GSMFR_decinst_t* decInst, int16_t* input )
{
	return 0;
}

int16_t WebRtcGSMFR_DecodePlc( GSMFR_decinst_t* decInst )
{
	return 0;
}

int16_t WebRtcGSMFR_DecoderInit( GSMFR_decinst_t* decInst )
{
	return 0;
}

